<!DOCTYPE html>
<html>
<head>
    <meta charset="utf-8">
    <title>Vue中同时使用过渡和动画</title>
    <script src="../lib/vue.js" type="text/javascript" charset="utf-8"></script>
    <link rel="stylesheet" type="text/css" href="../lib/animate.css">
</head>
<body>
<!--    添加放大和缩小的动态效果-->
<!--添加 appear 解决第一次添加无动画的问题-->
<!--添加 type="transition" ，解决同时执行多个动画时时长不同的问题，
以 transition 为准，也可以添加 ：duration="5000",就以手动设置5s为动画时长-->

<div id="root">
    <transition
            name="fade"
            type="transition"
            appear
            enter-active-class="animated fadeInUp fade-enter-active"
            leave-active-class="animated shake fade-leave-active"
            appear-active-class="animated fadeInUp"
    >
        <div v-if="show">hello world</div>
    </transition>
    <button @click="handleClick">切换</button>
</div>
<script type="text/javascript">
    var vm = new Vue({
        el: "#root",
        data: {
            show: true
        },
        methods: {
            handleClick: function () {
                this.show = !this.show
            }
        },
    });
</script>
<style type="text/css">
    .fade-enter {
        opacity: 0;
    }

    /*显示时：第二帧出现，整个生命周期都存在，监听 transition 的变化*/
    .fade-enter-active {
        transition: opacity 3s;
    }

    /*隐藏时：第二帧出现*/
    .fade-leave-to {
        opacity: 0;
    }

    /*隐藏时：整个生命周期都存在，动画结束后才被取消，监听 transition 的变化*/
    .fade-leave-active {
        transition: opacity 3s;
    }
</style>
</body>
</html>
